CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

PROJECT(CLI)

FILE(GLOB_RECURSE CLI_SRC
		"${PROJECT_SOURCE_DIR}/src/*.cpp"
		"${PROJECT_SOURCE_DIR}/src/*.h"
		"${PROJECT_SOURCE_DIR}/include/agz/cli/*.h"
		"${PROJECT_SOURCE_DIR}/include/agz/cli/*.inl")
ADD_EXECUTABLE(CLI ${CLI_SRC})

FOREACH(_SRC IN ITEMS ${CLI_SRC})
    GET_FILENAME_COMPONENT(CLI_SRC "${_SRC}" PATH)
    STRING(REPLACE "${PROJECT_SOURCE_DIR}/include/agz/cli" "cli/include" _GRP_PATH "${CLI_SRC}")
    STRING(REPLACE "${PROJECT_SOURCE_DIR}/src" "cli/src" _GRP_PATH "${_GRP_PATH}")
    STRING(REPLACE "/" "\\" _GRP_PATH "${_GRP_PATH}")
    SOURCE_GROUP("${_GRP_PATH}" FILES "${_SRC}")
ENDFOREACH()

IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    TARGET_COMPILE_OPTIONS(CLI PUBLIC "-pthread")
ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    TARGET_COMPILE_OPTIONS(CLI PUBLIC "-pthread")
ENDIF()

SET_PROPERTY(TARGET CLI PROPERTY CXX_STANDARD 17)
SET_PROPERTY(TARGET CLI PROPERTY CXX_STANDARD_REQUIRED ON)

IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
	IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
		SET(LINKER_FLAGS "-lc++fs -ldl -pthread")
	ELSE()
		SET(LINKER_FLAG "-lstdc++fs -ldl -pthread")
	ENDIF()
ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    SET(LINKER_FLAGS "-lstdc++fs -ldl -pthread")
ENDIF()

TARGET_INCLUDE_DIRECTORIES(CLI PUBLIC "${PROJECT_SOURCE_DIR}/include")

TARGET_LINK_LIBRARIES(CLI Tracer Factory AGZUtils ${LINKER_FLAGS})
